<% native_coin = Explorer.coin_name() %>
<!-- USD value of the balance -->
<% wei_value = if @address.fetched_coin_balance, do: @address.fetched_coin_balance.value %>
<% raw_usd_value =
    case @exchange_rate.usd_value do
        %Decimal{} ->
            if wei_value do
                %Wei{value: Decimal.new(wei_value)}
                |> Wei.to(:ether)
                |> Decimal.mult(@exchange_rate.usd_value)
            else
                Decimal.new(0)
            end
        _ -> Decimal.new(0)
    end
%>
<% data_usd_exchange_rate =
    unless AddressView.empty_exchange_rate?(@exchange_rate) do
        "data-usd-exchange-rate='#{@exchange_rate.usd_value}' data-raw-usd-value='#{raw_usd_value}'"
    end
%>
<% native_coin_balance_token = AddressView.balance(@address)
%>
<% native_coin_balance_usd =
    if AddressView.empty_exchange_rate?(@exchange_rate) do
        nil
    else
        "<span
            data-wei-value='#{wei_value}'
            #{data_usd_exchange_rate}
        >
        </span>"
    end
%>
<% native_coin_balance =
    if native_coin_balance_usd do
        native_coin_balance_usd <> " | " <> native_coin_balance_token
    else
        native_coin_balance_token
    end
%>
<div class="d-md-flex">
    <%= render BlockScoutWeb.AddressTokenView, "overview_item.html",
        title: gettext("Net Worth"),
        tooltip: gettext("Shows total assets held in the address"),
        value: "N/A",
        data_test: "address-tokens-panel-net-worth",
        classes: ["fs-14"]
    %>
    <%= render BlockScoutWeb.AddressTokenView, "overview_item.html",
        title: "#{native_coin} #{gettext("Balance")}",
        tooltip: "#{gettext("Shows the current")} #{native_coin} #{gettext("balance of the address")}",
        value: raw(native_coin_balance),
        data_test: "address-tokens-panel-native-worth",
        classes: ["fs-14"]
    %>
    <%= render BlockScoutWeb.AddressTokenView, "overview_item.html",
        title: gettext("Tokens"),
        tooltip: gettext("Shows the tokens held in the address (includes ERC-20, ERC-721 and ERC-1155)."),
        value: "N/A",
        data_test: "address-tokens-panel-tokens-worth",
        classes: ["fs-14"]
    %>
    <%= render BlockScoutWeb.AddressTokenView, "overview_item.html",
        title: gettext("CRC Worth"),
        tooltip: gettext("Shows the total CRC balance in the address."),
        value: "0 CRC",
        data_test: "address-tokens-panel-crc-total-worth",
        data_test_container: "address-tokens-panel-crc-total-worth-container",
        classes: ["fs-14"],
        container_classes: ["d-none"]
    %>
</div>
